<?php

namespace app\site\controller;

use app\common\exception\MiException;
use app\site\service\SignService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

class SignController extends AController
{
    /**
     * @throws DbException
     * @throws MiException
     */
    public function index(){
        $ser = SignService::instance();
        return $this->reqSer->setService($ser)->setPaginate()->getResponse();
    }

    /**
     * @throws MiException
     */
    public function add(){
        $ser = SignService::instance();
        return $this->reqSer->setService($ser)->add()->getResponse();
    }

    /**
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws MiException
     */
    public function edit(){
        $ser = SignService::instance();
        if (request()->isPost()){
            return $this->reqSer->setService($ser)->edit()->getResponse();
        }else{
            return $this->reqSer->setService($ser)->setFind()->getResponse();
        }
    }

    /**
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws MiException
     */
    public function del()
    {
        return $this->reqSer->setService(SignService::instance())->delete()->getResponse();
    }

}
